package com.yidu.t299.dao.ljc;
import com.yidu.t299.domain.ljc.Goodstock;
import org.apache.ibatis.annotations.*;
import java.util.List;

/**
 * @author 刘建常
 * @version 1.0
 * @description
 * @date:2023/3/16 9:23
 */
@Mapper
public interface GoodstockMapper {
    /**
     * 删除
     * @param goodsStockId
     * @return
     */
    @Delete({
            "delete from goods_stock" +
                    " where goods_stock_id = #{goodsStockId,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer goodsStockId);

    /**
     * 添加
     * @param record
     * @return
     */
    @Insert({
            "insert into goods_stock (goods_stock_id,in_name,in_price,in_number)" +
                    " values (#{goodsStockId,jdbcType=INTEGER}, #{inName,jdbcType=VARCHAR}," +
                    "#{inPrice,jdbcType=DOUBLE},#{inNumber,jdbcType=INTEGER})"
    })
    int insert(Goodstock record);

    /**
     * 查询
     */
    @Select({
            "select" +
                    " goods_stock_id, in_name,in_price,in_number" +
                    " from goods_stock" +
                    " where goods_stock_id = #{goodsStockId,jdbcType=INTEGER}"
    })
    @Results(id = "GoodstockMap",value = {
            @Result(id = true,column = "goods_stock_id",property = "goodsStockId"),
            @Result(column = "in_name",property = "inName"),
            @Result(column = "in_price",property = "inPrice"),
            @Result(column = "in_number",property = "inNumber")
    })
    Goodstock selectByPrimaryKey(Integer goodsStockId);


    @Select("select * from goods_stock where 1=1 ${condition} limit #{page},#{rows}")
    @ResultMap("GoodstockMap")
    List<Goodstock> selectByPage(@Param("rows") int rows, @Param("page") int page, @Param("condition") String condition);

    @Select("select count(*) from goods_stock where 1=1 ${condition}")
    int selectCount(@Param("condition") String condition);


    @Update({
            "update goods_stock"+
                    " set in_name = #{inName,jdbcType=VARCHAR},"+
                    " in_price = #{inPrice,jdbcType=INTEGER},"+
                    " in_number = #{inNumber,jdbcType=VARCHAR}"+
                    " where goods_stock_id = #{goodsStockId,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(Goodstock record);
}
